/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sudoku;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 *
 * @author Roy
 */
public class MainFrame extends JFrame implements ActionListener {

	private Sudoku sudoku;

	private void initialSudoku() {
		sudoku = new Sudoku();
		add("Center", sudoku);
	}

	private void initialButtonsPanel() {
		JPanel buttons = new JPanel();
		JButton solveButton = new JButton("solve");

		buttons.setLayout(new FlowLayout());
		solveButton.setActionCommand("solve");
		solveButton.addActionListener(this);
		buttons.add(solveButton);
		add("South", buttons);
	}

	public MainFrame() {
		setLayout(new BorderLayout());

		initialSudoku();
		initialButtonsPanel();

		pack();

		addWindowListener(new WindowAdapter() {
			public void WindowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}

	public void actionPerformed(ActionEvent e) {
		sudoku.solve();
	}

}
